package cn.itsource.ymcc.client;

import cn.itsource.ymcc.domain.CourseDoc;
import cn.itsource.ymcc.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ESFeignClientFallbackFactory implements FallbackFactory<ESFeignClient> {
    @Override
    public ESFeignClient create(Throwable throwable) {
        return new ESFeignClient() {

            @Override
            public JsonResult saveCourse(CourseDoc courseDoc) {
                throwable.printStackTrace();
                return JsonResult.error(throwable.getMessage());
            }

            @Override
            public JsonResult delCourse(Long id) {
                throwable.printStackTrace();
                return JsonResult.error(throwable.getMessage());
            }

            @Override
            public JsonResult findCourseDocByCourseId(Long courseId) {
                throwable.printStackTrace();
                return JsonResult.error("findCourseDocByCourseId:"+throwable.getMessage());
            }

            @Override
            public JsonResult findCourseDocByCourseIds(List<Long> courseIds) {
                throwable.printStackTrace();
                return JsonResult.error("findCourseDocByCourseIds:"+throwable.getMessage());
            }


        };
    }
}
